package com.bsc.rtc.lib.libraries.BannerDemo;

import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;

import com.bsc.rtc.lib.libraries.R;
import com.youth.banner.Banner;
import com.youth.banner.BannerConfig;
import com.youth.banner.Transformer;
import com.youth.banner.listener.OnBannerListener;

import java.util.ArrayList;
import java.util.List;

public class BannerDemoActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_banner_demo);
        initBanner();
    }
    private void initBanner(){
        Banner banner = (Banner) findViewById(R.id.banner);
        //设置banner样式
        banner.setBannerStyle(BannerConfig.CIRCLE_INDICATOR);
        //设置图片加载器
        banner.setImageLoader(new GlideImageLoader());
        //设置图片集合
        List<String> listurls= new ArrayList<String>();
        listurls.add("https://www.discuz.images.zq.sd.cn/Discuz/forum/201401/24/232552w337e74ijeub3k73.jpg");
        listurls.add("https://www.discuz.images.zq.sd.cn/Discuz/forum/201401/29/112216urbd2o85ssdiroz5.jpg");
        listurls.add("http://img2.imgtn.bdimg.com/it/u=1884748137,3269089153&fm=214&gp=0.jpg");
        banner.setImages(listurls);
        //设置banner动画效果
        banner.setBannerAnimation(Transformer.DepthPage);
        //设置标题集合（当banner样式有显示title时）
        List<String> list= new ArrayList<String>();
        list.add("");
        list.add("");
        list.add("");
        banner.setBannerTitles(list);
        //设置自动轮播，默认为true
        banner.isAutoPlay(true);
        //设置轮播时间
        banner.setDelayTime(2000);
        //设置指示器位置（当banner模式中有指示器时）
       // banner.setIndicatorGravity(BannerConfig.CENTER);
        banner.setIndicatorGravity(BannerConfig.RIGHT);
        //banner设置方法全部调用完毕时最后调用

        banner.setOnBannerListener(new OnBannerListener() {
            @Override
            public void OnBannerClick(int position) {
                Log.i("zzw","position="+position);
            }
        });
        banner.start();
    }

}
